package shm;

import java.util.Vector;

/**
 * 
 * Class used to store WSN Mote related information. Only for display purpose.
 *
 */
public class NodeInformation {
	public int Id;				// Node ID
	public int Parent= -1;		// parent node id.
	
	public int X;				// X , y Position
	public int Y;
	
	public int Ext;
	public int LinkQuality;
	
	public boolean state = true;
	
	public static void init()
	{
		vec = new Vector<NodeInformation>();
		
		// create the gateway node.
		NodeInformation ni = new NodeInformation();
		ni.Id=0;
		ni.Parent=-1;
		
		ni.X=325;
		ni.Y=200;
		vec.add(ni);
	}
	
	// storing all connected node
	public static Vector<NodeInformation> vec;

    
    
    // Node Operation
    
	public static NodeInformation creatNode(int nodeId, int parent,int x,int y, int ext,int quality)
	{
		NodeInformation ni = new NodeInformation();
		ni.Id=nodeId;
		ni.Parent = parent;
		ni.X=x;
		ni.Y=y;
		ni.Ext=ext;
		ni.LinkQuality=quality;
		
		vec.addElement(ni);
		
		return ni;
	}
    
	public static int getParent(int id)
	{
		int p = -1;
		for (NodeInformation i : vec)
    	{
    		if (i.Id == id)
    		{
    			p = i.Parent;
    		}
    	}
		return p;
	}
	
	public static NodeInformation getNode(int id)
	{
		for (NodeInformation i : vec)
    	{
    		if (i.Id == id)
    		{
    			return i;
    		}
    	}
		return null;
	}
	
	public static int getSize()
	{
		return vec.size();
	}
	
	public static NodeInformation getNodeAt(int index)
	{
		return vec.elementAt(index);
	}
    
}
